﻿using System.Collections.Generic;
using System.Reflection;
using CommandLine;
using CommandLine.Text;

namespace ExcelAutomator.Console
{
	internal class CommandLineOptions
	{
		[Option("c", "configFile", Required = true, HelpText = "Xml configuration file, defining the automation executors.")]
		public string ConfigurationFile;

		[Option("i", "input", Required = false, HelpText = "Excel input file(s)/folder to process (overrides the configFile settings).")]				
		public string Input = null;

		[OptionList("p", "searchPattern", Separator = ';', HelpText = "Search pattern. Allows to filter for specific file extensions in the input folder. Default value = *.xls;*.xlsx;*.xlsm")]
		public IList<string> SearchPattern = new List<string>() { "*.xls", "*.xlsx", "*.xlsm" };

		[Option("x", "scanSubFolders",
		HelpText = "Includes the sub folders of the 'inputFolder' or not. Default value = false")]
		public bool ScanSubFolders = false;

		[Option("o", "outputFolder", HelpText = "Output directory for the processed excel files.")]
		public string OutputFolder = null;
		
		
		[HelpOption(HelpText = "Display this help screen.")]
		public string GetUsage()
		{
			var help = new HelpText(new HeadingInfo("Excel Automator", string.Format("v.{0}", Assembly.GetExecutingAssembly().GetName().Version)))
			           	{
			           		AdditionalNewLineAfterOption = true,
			           		Copyright = new CopyrightInfo("Andreas Taube (andreas.taube@gmx.de)", 2011)
			           	};

			help.AddPreOptionsLine("\n");
			help.AddPreOptionsLine("Description:");
			help.AddPreOptionsLine("Automates Excel via a XML based configuration. Please see the documention for the configuration file definition.");
			help.AddPreOptionsLine("");
			help.AddPostOptionsLine("Usage: ExcelAutomator.exe -c config.xml");
			help.AddPostOptionsLine(@"Usage: ExcelAutomator.exe -c config.xml -i C:\Temp\MyDocument.xls");
			help.AddPostOptionsLine(@"Usage: ExcelAutomator.exe -c config.xml -i C:\Temp\Documents");
			help.AddPostOptionsLine(string.Empty);
			help.AddOptions(this);

			
			return help;
		}


	}
}
